﻿using System;
using System.Globalization;
using System.Windows.Data;

namespace WinRTConverters.WP8.Visibility
{
    public class ValueNotEqualNullToVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo language)
        {
            if (value != null)
            {
                if (parameter != null)
                {
                    var invert = (bool)parameter;
                    return invert ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible;
                }
                return System.Windows.Visibility.Visible;
            }
            else
            {
                if (parameter != null)
                {
                    var invert = (bool)parameter;
                    return invert ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed;
                }
                return System.Windows.Visibility.Collapsed;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo language)
        {
            throw new NotImplementedException();
        }
    }
}
